package com.zhou.project.modules.system.user.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.zhou.project.components.base.entity.Base;
import com.zhou.project.components.validation.Password;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;
import java.util.Date;

/**
 * @project spring-boot-project
 * @author zhouhonggang
 * @datetime 2021/8/11 13:42
 * @version 1.0.0
 * @description: 用户实体类
 */

@Getter
@Setter
@TableName(value = "system_user_info")
@ApiModel("[系统管理-用户管理-数据模型]")
public class SysUser extends Base {
    @ApiModelProperty(name = "name", value = "姓名", required = true, dataType = "String")
    @NotBlank(message = "姓名不允许为空")
    @Length(min = 2, max = 15, message = "姓名长度要求在{min}-{max}之间")
    private String name;

    @ApiModelProperty(name = "nick", value = "昵称", required = true, dataType = "String")
    @NotBlank(message = "昵称不允许为空")
    @Length(min = 2, max = 15, message = "昵称长度要求在{min}-{max}之间")
    private String nick;

    @ApiModelProperty(name = "account", value = "登陆账号", required = true, dataType = "String")
    @NotBlank(message = "登陆账号不允许为空")
    @Length(min = 5, max = 16, message = "登陆账号长度要求在{min}-{max}之间")
    private String account;

    @ApiModelProperty(name = "password", value = "登陆密码", required = true, dataType = "String")
    @NotBlank(message = "登陆密码不允许为空")
    @Length(min = 6, max = 16, message = "登陆密码长度要求在{min}-{max}之间")
    @Password(message = "登陆密码强度太低风险太高")
    private String password;

    @ApiModelProperty(name = "phone", value = "手机号码", required = true, dataType = "String")
    @NotBlank(message = "手机号码不允许为空")
    @Pattern(
        regexp = "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$",
        message = "请输入正确的手机号码"
    )
    private String phone;

    @ApiModelProperty(name = "email", value = "电子邮箱", required = true, dataType = "String")
    @Length(min = 6, max = 35, message = "电子邮箱长度要求在{min}-{max}之间")
    @Email(message = "电子邮箱必须符合规范")
    private String email;

    @ApiModelProperty(name = "birthday", value = "出生日期", required = true, dataType = "Date")
    @NotNull(message = "出生日期不允许为空")
    @Past(message = "出生日期必须是当前日期之前")
    private Date birthday;

    @ApiModelProperty(name = "locked", value = "0:启用 1:锁定", required = true, dataType = "Integer")
    private Integer locked = 0;
}
